package com.shop.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shop.entity.Category;
import org.apache.ibatis.annotations.*;

@Mapper
public interface CateGoryMapper extends BaseMapper<Category> {
    @Insert("insert into sp_category (cat_name,cat_pid,cat_level) values(#{cat_name},#{cat_pid},#{cat_level})")
    @Options(useGeneratedKeys = true,keyProperty = "cat_id")
    Category add(Category category);

    @Select("SELECT cat_id ,cat_name,cat_pid,cat_level FROM sp_category WHERE cat_id=#{id};" )
    Category findById(Integer id);



    @Update("update sp_category set cat_name=#{cat_name},cat_pid=#{cat_pid},cat_level=#{cat_level} where cat_id=#{cat_id}")
    void update(Category category);
}
